#ifndef _SPI_H
#define _SPI_H

#include "types.h"
#include "avr\io.h"


#define SET_CE()    SET( PORTB, 3 )
#define CLR_CE()    CLR( PORTB, 3 )

#define SET_CSN()    SET( PORTB, 4 )
#define CLR_CSN()    CLR( PORTB, 4 )

#define SET_MOSI()   SET( PORTB, 5 )
#define CLR_MOSI()   CLR( PORTB, 5 )

#define SET_MISO()   SET( PORTB, 6 )
#define GET_MISO()   ( PINB & (1 << 6) )

#define SET_SCK()    SET( PORTB, 7 )
#define CLR_SCK()    CLR( PORTB, 7 )

//sbit CE =  P2^0;
//sbit SCK=  P1^7;
//sbit MISO= P1^6;
//sbit MOSI= P1^5;
//sbit CSN=  P1^4;
//sbit IRQ = P3^2;

//EXTERN FUNCTIONS
UINT8 SPI_Read_Reg( UINT8 reg );
void SPI_Read_Buf(UINT8 reg, UINT8 *pBuffer, UINT8 Length);
void SPI_Write_Reg(UINT8 reg, UINT8 value);
void SPI_Write_Buf(UINT8 reg, UINT8 *pBuffer, UINT8 Length);
UINT8 SPI_Verify_Buf(UINT8 reg, UINT8 *pBuffer, UINT8 Length);


#endif

